/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.freedoit.gui;

import java.awt.Component;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author wanglei
 */
public class ActionItemRenderer implements ListCellRenderer {
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        ActionPanel c = null;
        if (value instanceof ActionPanel) {
            c =((ActionPanel) value);
            c.setBackground(null);
        }
        
        if (c != null) {
            if (isSelected) {
                c.setBackground(list.getSelectionBackground());
                c.setSelectedBg(isSelected, list.getSelectionBackground());
            } else {
                //System.out.println(list.getBackground());
                c.setBackground(list.getParent().getBackground());
                c.setSelectedBg(isSelected, list.getParent().getBackground());
            }
        }
        return c;
    }}
